import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
Vue.use(uView);
Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()

const BaseUrl = "http://qiquan.younuos.com/";
const siteBaseUrl = "http://qiquan.younuos.com/Inter/";

//const BaseUrl = "http://localhost/poexr/";
//const siteBaseUrl = "http://localhost/poexr/Inter/";

Vue.prototype._post = function (url, data, success, fail) {
    //拼接完整请求地址
    //console.log(data);
    var requestUrl = siteBaseUrl + url;
    //固定参数
    data.ver = "1.0.1";
    // #ifdef MP-WEIXIN
    data.device = "wxapp";
    // #endif
    // #ifdef APP-PLUS || H5
    data.device = "iosapp";
    // #endif
    var header = {
        'content-type': "application/x-www-form-urlencoded"
    };
    console.log("网络请求start");
    //网络请求
    uni.request({
        url: requestUrl,
        method: "POST",
        header: header,
        data: data,
        success: res => {
            var code = res.data.data;
            uni.hideLoading();
            if (res.data.status != 1) { //返回结果码code判断:0成功,1错误,-1未登录(未绑定/失效/被解绑)
                return uni.showModal({
                    showCancel: false,
                    content: res.data.msg,
                    success: function () {
                        return;
                    }
                });
            }
            success && success(res.data);
        },
        fail: (e) => {
            uni.hideLoading();
            //console.log("网络请求fail:" + JSON.stringify(e));
            uni.showModal({
                content: "网络请求fail:" + e.errMsg
            });
            fail && fail(e);
        },
        complete: () => {
            console.log("网络请求complete");
        }
    });
}
